package com.lantu.wisdom.common.jms.jms;

import com.alibaba.fastjson.JSONObject;
import com.lantu.wisdom.mapper.PayDetailsMapper;
import com.lantu.wisdom.service.PayDetailApi;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;

@Component
@Slf4j
public class ConsumerJms {


    @Autowired
    private PayDetailsMapper userBillDetailsMapper;

    @Autowired
    private PayDetailApi userBillService;


    @JmsListener(destination = JmsType.JMS_LTJD_JDXCX, containerFactory = "myJmsListenerContainerFactory")
    void orderMsg(String json) {
        JSONObject jsonObject=JSONObject.parseObject(json);
        String orderCode=jsonObject.getString("order");
        BigDecimal money=new BigDecimal(jsonObject.getString("money"));
        //TODO 处理订单
        userBillService.Pay(orderCode,  money);
    }
}
